package com.flink.ttest.weartMark;

import com.alibaba.fastjson.JSON;
import com.flink.ttest.cofig.Order;
import org.apache.flink.streaming.api.functions.AssignerWithPeriodicWatermarks;
import org.apache.flink.streaming.api.watermark.Watermark;
/** 
 * @author: LCG
 * @date: 2022-07-01 15:51:36
 * @description:  周期性水印  这个已经过期  不知道替代品是谁
 */
public class MyWaterMark implements AssignerWithPeriodicWatermarks<String> {
 
    private final long maxTimeLag = 3000; // 3 seconds
 
    @Override
    public long extractTimestamp(String  str, long previousElementTimestamp) {

        Order order = JSON.parseObject(str, Order.class);
        return order.orderDate;
    }
 
    @Override
    public Watermark getCurrentWatermark() {

        return new Watermark(System.currentTimeMillis() - maxTimeLag);
    }
}